package user

import (
	"github.com/labstack/echo"
	"tacitus/library/authorized"
)

func RouteApi(g *echo.Group)  {
	g.POST("/register", RegisterHandler)
	g.POST("/login", LoginHandler)
	g.POST("/info", GetInfoHandler, auth.CheckLogin)
	g.POST("/update/info", UpdateInfoHandler, auth.CheckLogin)
	g.POST("/update/password", UpdatePasswordHandler, auth.CheckLogin)
}

func RouteHeadApi(g *echo.Group) {
	g.POST("/list", ShowHeadListHandler)
	g.POST("/set", SetUserHeadHandler, auth.CheckLogin)
	g.POST("/get", GetUserHeadHandler, auth.CheckLogin)
}

func RouteMobileApi(g *echo.Group)  {
	// 发送验证码
	g.POST("/captcha", SendCaptchaHandler)
	// 手机号登录
	g.POST("/login", LoginByMobileHandler)
	// 登录时选择，创建新用户
	g.POST("/login/new", CreateNewByMobileHandler)
	// 登录时选择，绑定已有用户
	g.POST("/login/bind", BindByMobileHandler)
	// 已登录用户，绑定手机号
	g.POST("/bind", BindMobileHandler, auth.CheckLogin)
}

func RouteAdminApi(g *echo.Group)  {
	g.POST("/list", ShowUserListHandler, auth.CheckAuth("user"))
	g.POST("/password/reset", ResetUserPasswordHandler, auth.CheckAuth("user.password"))
}